﻿#if HybridCLR
using HybridCLR;
#endif
using System;
using System.Reflection;
using UnityEngine;
/// <summary>
/// 游戏设定
/// </summary>
[Serializable]
public partial class GameSetting
{
    [SerializeField]
#if UNITY_EDITOR
    enILHotfixMode mILHotfixMode = enILHotfixMode.Editor;
#else
    enILHotfixMode mILHotfixMode = enILHotfixMode.HybridCLR;
#endif
    
    /// <summary>
    /// 资源包加载模式
    /// </summary>
    [SerializeField]
#if UNITY_EDITOR
    enHFAbLoadModel mHFAbLoadModel = enHFAbLoadModel.Editor;
#else
    enHFAbLoadModel mHFAbLoadModel = enHFAbLoadModel.PersistentData;
#endif

    /// <summary>
    /// 资源更新模式
    /// </summary>
    [SerializeField]
#if UNITY_EDITOR
    enHFAbUpdateModel mHFAbUpdateModel = enHFAbUpdateModel.Local;
#else
    enHFAbUpdateModel mHFAbUpdateModel = enHFAbUpdateModel.UrlUpate;
#endif

#if HybridCLR
    /// <summary>
    /// HybridCLR_AOT 模式
    /// </summary>
    [SerializeField]
    HomologousImageMode mHFHybridCLR_AOT_HomologousImageMode = HomologousImageMode.SuperSet;
#endif
    /// <summary>
    /// 是否边玩边下
    /// </summary>
    [SerializeField]
    bool mIsDownloadWhilePlaying = false;

    /// <summary>
    /// 热更模式
    /// </summary>
    public enum enILHotfixMode
    {
        /// <summary>
        /// 编辑器模式
        /// </summary>
        Editor,
        /// <summary>
        /// ILRuntime
        /// </summary>
        ILRuntime,
        /// <summary>
        /// HybridCLR
        /// </summary>
        HybridCLR,
    }

    /// <summary>
    /// 热更模式
    /// </summary>
    public enILHotfixMode ilHotfixMode { get { return mILHotfixMode; } }
    /// <summary>
    /// 资源加载模式
    /// </summary>
    public enHFAbLoadModel abLoadModel { get {
            if (mILHotfixMode == enILHotfixMode.Editor)
            {
                mHFAbLoadModel = enHFAbLoadModel.Editor;
            }
            return mHFAbLoadModel ; 
        } }
    /// <summary>
    /// 资源更新模式
    /// </summary>
    public enHFAbUpdateModel abUpdateModel { get { return mHFAbUpdateModel; } }
#if HybridCLR
    /// <summary>
    /// HybridCLR_AOT 模式
    /// </summary>
    [SerializeField]
    public HomologousImageMode dllHybridCLR_AOT_HomologousImageMode { get { return mHFHybridCLR_AOT_HomologousImageMode; } }
#endif
    /// <summary>
    /// 是否边玩边下
    /// </summary>
    public bool isDownloadWhilePlaying { get { return mIsDownloadWhilePlaying; } }

    /// <summary>
    /// 字段信息
    /// </summary>
    FieldInfo[] mFieldInfos = null;
    /// <summary>
    /// 复制设定
    /// </summary>
    /// <param name="_from">来源</param>
    public void CopyFrom(GameSetting _from)
    {
        if (mFieldInfos == null)
        {
            mFieldInfos = GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
        }
        if (mFieldInfos != null)
        {
            foreach (var f in mFieldInfos)
            {
                f.SetValue(this, f.GetValue(_from));
            }
        }
    }

  
}

